home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77683_log_clear.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  8.8 KB  |  275 lines

  1. <% @Language=VbScript%>
  2. <% Option Explicit    %>
  3. <%    '------------------------------------------------------------------------- 
  4.     ' Log_clear.asp : This page serves in clearing the logs
  5.     ' Copyright (c) Microsoft Corporation.  All rights reserved.
  6.     '-------------------------------------------------------------------------
  7. %>
  8.     <!--  #include virtual="/admin/inc_framework.asp"--->
  9.     <!--  #include file="loc_event.asp"--->
  10.     <!--  #include file="inc_log.asp"-->
  11. <% 
  12.     '-------------------------------------------------------------------------
  13.     ' Global Variables
  14.     '-------------------------------------------------------------------------
  15.     Dim page    
  16.     Dim rc
  17.     Const G_wbemPrivilegeSecurity=7 'Prilivilege constant
  18.  
  19.     '-------------------------------------------------------------------------
  20.     ' Form Variables
  21.     '-------------------------------------------------------------------------    
  22.     Dim F_strLogname                'Selected log name
  23.     
  24.     '-------------------------------------------------------------------------
  25.     ' Start of localization content
  26.     '-------------------------------------------------------------------------    
  27.     Dim arrTitle(1)            'Title text
  28.     Dim arrConfirm(1)        'Confirmation text
  29.  
  30.     
  31.     F_strLogname=Request.QueryString("title")
  32.     
  33.     If F_strLogname ="" Then
  34.         F_strLogname=Request.Form("hdnlogname")
  35.     End If
  36.     
  37.     'Localisation of page title
  38.     arrTitle(0)    =  GetLocalizationTitle(F_strLogname)
  39.         
  40.     L_PAGETITLE_CLR_TEXT = SA_GetLocString("event.dll", "403F0097", arrTitle)
  41.     
  42.     L_DELETE_CONFIRM_CLR_TEXT = SA_GetLocString("event.dll", "403F0099", arrTitle)
  43.     
  44.     'Create property page
  45.     Call SA_CreatePage(L_PAGETITLE_CLR_TEXT, "", PT_PROPERTY,page)
  46.     Call SA_ShowPage(Page)
  47.         
  48.     '-------------------------------------------------------------------------
  49.     'Function:                OnInitPage()
  50.     'Description:            Called to signal first time processing for this page.
  51.     '                        Use this method to do first time initialization tasks
  52.     'Input Variables:        PageIn,EventArg
  53.     'Output Variables:        None
  54.     'Returns:                True/False
  55.     'Global Variables:        None
  56.     '-------------------------------------------------------------------------
  57.     Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
  58.         OnInitPage = True
  59.     End Function
  60.     
  61.     '-------------------------------------------------------------------------
  62.     'Function:                OnServePropertyPage()
  63.     'Description:            Called when the page needs to be served.Use this 
  64.     '                        method to serve content
  65.     'Input Variables:        PageIn,EventArg
  66.     'Output Variables:        None
  67.     'Returns:                True/False
  68.     'Global Variables:        None
  69.     '-------------------------------------------------------------------------
  70.     Public Function OnServePropertyPage(ByRef PageIn,Byref EventArg)
  71.         Call ServeCommonJavaScript()
  72.         Call ServePage()
  73.         OnServePropertyPage = True
  74.     End Function
  75.     
  76.     '-------------------------------------------------------------------------
  77.     'Function:                OnPostBackPage()
  78.     'Description:            Called to signal that the page has been posted-back.
  79.     'Input Variables:        PageIn,EventArg
  80.     'Output Variables:        None
  81.     'Returns:                True/False
  82.     'Global Variables:        None
  83.     '-------------------------------------------------------------------------
  84.     Public Function OnPostBackPage(ByRef PageIn ,ByRef EventArg)
  85.         OnPostBackPage = True
  86.     End Function
  87.         
  88.     '-------------------------------------------------------------------------
  89.     'Function:                OnSubmitPage()
  90.     'Description:            Called when the page has been submitted for processing.
  91.     '                        Use this method to process the submit request.
  92.     'Input Variables:        PageIn,EventArg
  93.     'Output Variables:        None
  94.     'Returns:                True/False
  95.     'Global Variables:        None
  96.     '-------------------------------------------------------------------------
  97.     Public Function OnSubmitPage(ByRef PageIn ,ByRef EventArg)
  98.         OnSubmitPage = ServeVariablesFromForm()
  99.     End Function
  100.            
  101.     '-------------------------------------------------------------------------
  102.     'Function:                OnClosePage()
  103.     'Description:            Called when the page is about closed.Use this method
  104.     '                        to perform clean-up processing
  105.     'Input Variables:        PageIn,EventArg
  106.     'Output Variables:        None
  107.     'Returns:                True/False
  108.     'Global Variables:        None
  109.     '-------------------------------------------------------------------------
  110.     Public Function OnClosePage(ByRef PageIn ,ByRef EventArg)
  111.         OnClosePage = TRUE
  112.     End Function     
  113.     
  114.     '-------------------------------------------------------------------------
  115.     'Function:                ServeCommonJavaScript
  116.     'Description:            Serves in initialiging the values,setting the form
  117.     '                        data and validating the form values
  118.     'Input Variables:        None
  119.     'Output Variables:        None
  120.     'Returns:                True/False
  121.     'Global Variables:        None
  122.     '-------------------------------------------------------------------------
  123.     Function ServeCommonJavaScript()
  124. %>        
  125.         <script language="JavaScript" src ="<%=m_VirtualRoot%>inc_global.js">
  126.         </script>
  127.         <script language="JavaScript">
  128.                 
  129.             //Initialization
  130.             function Init()
  131.                 {
  132.                     SetPageChanged(false);
  133.                 }
  134.                   
  135.             //To validate user input  
  136.             function ValidatePage()
  137.                 {
  138.                        return true;
  139.                 } 
  140.                   
  141.             //Dummy function for Framework
  142.                 function SetData()
  143.                 {
  144.                     
  145.                 }
  146.         </script>
  147. <%    End Function
  148.    
  149.     '-------------------------------------------------------------------------
  150.     'Function:                ServePage()
  151.     'Description:            For displaying outputs HTML to the user
  152.     'Input Variables:        None    
  153.     'Output Variables:        None
  154.     'Returns:                None
  155.     'Global Variables:        L_DELETE_CONFIRM_TEXT
  156.     '-------------------------------------------------------------------------
  157.     Function ServePage
  158.     
  159.         Dim oEncoder
  160.         Set oEncoder = new CSAEncoder
  161.  
  162. %>
  163.     <table width="100%" border="0" cellspacing="0" cellpadding="0" >
  164.         <tr>
  165.             <td class="TasksBody">
  166.                 <%=oEncoder.EncodeElement(L_DELETE_CONFIRM_CLR_TEXT)%>
  167.             </td>
  168.         </tr>
  169.     </table>    
  170.     
  171.     <input type="hidden" name="hdnlogname" value="<%=F_strLogname%>">
  172.             
  173.         
  174. <%                
  175.     End Function
  176.     
  177.     '-------------------------------------------------------------------------
  178.     'Function name:            ServeVariablesFromForm()
  179.     'Description:            Serves in getting the data from Client 
  180.     'Input Variables:        None    
  181.     'Output Variables:        None
  182.     'Returns:                True/False
  183.     'Global Variables:        None
  184.     '-------------------------------------------------------------------------
  185.     Function ServeVariablesFromForm
  186.     
  187.     'Getting the selected log
  188.     If LogClear()then
  189.        ServeVariablesFromForm = true
  190.     else
  191.         ServeVariablesFromForm = false
  192.     end if    
  193.     End Function    
  194.     
  195.     '-------------------------------------------------------------------------
  196.     'Function name:            LogClear
  197.     'Description:            Serves in clearing the log
  198.     'Input Variables:        None    
  199.     'Output Variables:        None
  200.     'Returns:                True/False. True if successful else False
  201.     'Global Variables:        F_strLogname
  202.     'Clears events for the selected log
  203.     '------------------------------------------------------------------------
  204.     Function LogClear()
  205.         Err.clear
  206.         on Error Resume Next
  207.  
  208.         Dim objLog
  209.         Dim objConnection
  210.         Dim objLognames
  211.         Dim strQuery
  212.         Dim intResult
  213.         Const strDefault="Default"
  214.  
  215.         Dim oValidator
  216.  
  217.         '
  218.         ' Validate the log name, it's a QueryString argument.
  219.         Set oValidator = new CSAValidator
  220.         If ( FALSE = oValidator.IsValidIdentifier(F_strLogname)) Then
  221.             SA_SetErrMsg L_INVALIDPARAMETERS_ERRORMESSAGE
  222.             Call SA_TraceOut(SA_GetScriptFileName(), "Log name not valid: " & F_strLogname)
  223.             LogClear = False
  224.             Set oValidator = Nothing
  225.             Exit Function
  226.         End If
  227.         Set oValidator = Nothing
  228.         
  229.         strQuery="SELECT * FROM  Win32_NTEventlogFile WHERE LogfileName=" & "'" & F_strLogname & "'"
  230.         
  231.         'Getting the WMI connection
  232.         set objConnection = getWMIConnection(strDefault)
  233.         
  234.         'Passing the Privileges
  235.         'objConnection.Security_.Privileges.Add G_wbemPrivilegeSecurity    
  236.         
  237.         Set objLognames = objConnection.ExecQuery(strQuery)
  238.         If Err.number <> 0 Then
  239.             SA_SetErrMsg L_INVALIDPARAMETERS_ERRORMESSAGE
  240.             Call SA_TraceOut(SA_GetScriptFileName(), "ExecQuery(" & strQuery & ") failed: " & Hex(Err.Number) & " " & Err.Description)
  241.             LogClear = False
  242.             Exit Function
  243.         End If
  244.  
  245.         'Clearing events in the selected log
  246.         For Each objLog in objLognames
  247.             intResult=objLog.ClearEventlog()
  248.         Next
  249.         
  250.         If (Err.number <> 0 OR intResult <> 0 )Then
  251.             'Checking for access error
  252.             If Err.number = -2147217405 Then
  253.                 SA_SetErrMsg L_LOGACCESSDENIED_ERRORMESSAGE
  254.             'Log clear error
  255.             Elseif Err.number = 438 then
  256.                 SA_SetErrMSG L_LOGCLEARFAIL_ERRORMESSAGE
  257.             Else
  258.             'Log not cleared
  259.                 SA_SetErrMsg L_LOGNOTCLEARED_ERRORMESSAGE
  260.             End If
  261.             
  262.             Call SA_TraceOut(SA_GetScriptFileName(), "ClearEventLog failed: " & Hex(Err.Number) & " " & Err.Description)
  263.             LogClear = FALSE
  264.             Exit Function
  265.         End IF
  266.         
  267.         LogClear = TRUE
  268.         
  269.         'Setting object to nothing
  270.         Set objConnection=Nothing
  271.         'Setting logname to nothing
  272.         Set objLognames=Nothing
  273.     End function
  274. %>    
  275.